package com.qf.proxy.jdkproxy;


import com.qf.proxy.jdkproxy.demo1.Marry;
import com.qf.proxy.jdkproxy.demo1.You;
import com.qf.proxy.staticproxy.demo1.House;
import com.qf.proxy.staticproxy.demo1.HouseOwner;
import org.junit.Test;

/**
 * @author lwc
 * @date 2021/10/27 11:48
 * @Description
 */
public class TestJdkProxy {

    @Test
    public void test1(){
        //真实对象
        Marry marry= new You();
        JdkProxy jdkProxy = new JdkProxy();
        //得到代理对象
        Marry target = (Marry) jdkProxy.getTarget(marry);

        //调用方法
        int money = target.money();
        System.out.println(money);
        target.marry();

    }

    @Test
    public void test2(){
        //创建真实对象
        House houseOwner = new HouseOwner();

        //得到代理对象
        JdkProxy jdkProxy = new JdkProxy();
        House target = (House) jdkProxy.getTarget(houseOwner);
        //调用方法
        target.rent();
    }

}
